<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/**
 * @author Anh Nguyen <duyanhnguyen@vccorp.vn>
 * @copyright 2012
 * @property Post_model $post_model
 */
class Discount extends MX_Controller
{
    private $_langCode;

    function __construct()
    {
        parent::__construct();
        $this->load->library('Layout');
        $this->_langCode = $this->mycommon->getLangCode();
        session_start();
        unset($_SESSION['search']);
    }

    public function index($page='')
    {
        
    	$page = (intval($page) != 0) ? intval($page) : 1;

    	$price_status = 1;
        $data = array();
        $this->load->model('option/option_model');
        $this->load->model('category/category_model');
        $this->load->model('post/post_model');
        $this->load->model('list_network/list_network_model');
        $this->load->model('item_sim/item_sim_model');
        $this->load->model('list_group/list_group_model');
        
        $tmpInfo = $this->list_network_model->getListNetwork();
        $listGroup = $this->list_group_model->getListGroup();
        //array sim giam gia.
        //start phan tran
        $this->load->library('Pagination');
        $numPost = $this->item_sim_model->getNumAll(1);
        
        $config['base_url'] = base_url('giamgia/sim_gia_tot');
        $config['prefix'] = ($this->_langCode == 'vietnam') ? 'trang_' : 'page_';
        $config['suffix'] = '.html';
        $config['total_rows'] = $numPost;
        
        $config['per_page'] = 2;
        
        $config['cur_page'] = $page;
        $config['use_page_numbers'] = TRUE;
        $config['first_link'] = '«';
        $config['last_link'] = '»';
        $config['cur_tag_open'] = '<a class="active-page">';
        $config['cur_tag_close'] = '</a>';
        $config['num_links'] = 6;
        $config['uri_segment'] = 3;
        $this->pagination->initialize($config);
        $start = ($page - 1) * $config['per_page'];

        $data['pagination'] = $this->pagination->create_links();
        //end phan trag
        $post = $this->item_sim_model->getAllByPrice($price_status,$config['per_page'], $start);
	
        $data['page'] = $page;
        $data['list_network'] = $tmpInfo;
        $data['list_group'] = $listGroup;
        $data['post'] = $post;
        $this->layout->view('landing/landing_view', $data);
    }
    
    public function change()
    {
        $data = array();
    	$this->load->model('option/option_model');
    	$this->load->model('category/category_model');
    	$this->load->model('post/post_model');
    	$this->load->model('list_network/list_network_model');
    	$this->load->model('item_sim/item_sim_model');
    	$this->load->model('list_group/list_group_model');
    
    	$tmpInfo = $this->list_network_model->getListNetwork();
    	$listGroup = $this->list_group_model->getListGroup();
    
    	$data['list_network'] = $tmpInfo;
    	$data['list_group'] = $listGroup;
    
    	$this->layout->view('landing/change_view', $data);
    }
    public function support()
    {
    	$data = array();
    	$this->load->model('option/option_model');
    	$this->load->model('category/category_model');
    	$this->load->model('post/post_model');
    	$this->load->model('list_network/list_network_model');
    	$this->load->model('item_sim/item_sim_model');
    	$this->load->model('list_group/list_group_model');
    
    	$tmpInfo = $this->list_network_model->getListNetwork();
    	$listGroup = $this->list_group_model->getListGroup();
    
    	$data['list_network'] = $tmpInfo;
    	$data['list_group'] = $listGroup;
    
    	$this->layout->view('landing/support_view', $data);
    }
    public function about()
    {
    	$data = array();
    	$this->load->model('option/option_model');
    	$this->load->model('category/category_model');
    	$this->load->model('post/post_model');
    	$this->load->model('list_network/list_network_model');
    	$this->load->model('item_sim/item_sim_model');
    	$this->load->model('list_group/list_group_model');
    
    	$tmpInfo = $this->list_network_model->getListNetwork();
    	$listGroup = $this->list_group_model->getListGroup();
    
    	$data['list_network'] = $tmpInfo;
    	$data['list_group'] = $listGroup;
    
    	$this->layout->view('landing/about_view', $data);
    }
    public function sales()
    {
    	$data = array();
    	$this->load->model('option/option_model');
    	$this->load->model('category/category_model');
    	$this->load->model('post/post_model');
    	$this->load->model('list_network/list_network_model');
    	$this->load->model('item_sim/item_sim_model');
    	$this->load->model('list_group/list_group_model');
    
    	$tmpInfo = $this->list_network_model->getListNetwork();
    	$listGroup = $this->list_group_model->getListGroup();
    
    	$data['list_network'] = $tmpInfo;
    	$data['list_group'] = $listGroup;
    
    	$this->layout->view('landing/sales_view', $data);
    }
    public function contact()
    {
    	$data = array();
    	$this->load->model('option/option_model');
    	$this->load->model('category/category_model');
    	$this->load->model('post/post_model');
    	$this->load->model('list_network/list_network_model');
    	$this->load->model('item_sim/item_sim_model');
    	$this->load->model('list_group/list_group_model');
    
    	$tmpInfo = $this->list_network_model->getListNetwork();
    	$listGroup = $this->list_group_model->getListGroup();
    
    	$data['list_network'] = $tmpInfo;
    	$data['list_group'] = $listGroup;
    
    	$this->layout->view('landing/contact_view', $data);
    }

}
?>
